package com.elitecore.beans;

import java.util.Arrays;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;

@Aspect
public class TestAOP
{
	/*
	
	@Before("execution(* com.elitecore.beans.UserInfo.display(..)) && args(str)")
	public void beforeAOPMethod(String str)
	{
		System.out.println("Before Aspect In TestAOPMethod Method==="+str);
	}
	*/

	@Before("execution(* com.elitecore.beans.UserInfo.display(..))")
	public void beforeAOPMethod()
	{
		System.out.println("Before Aspect In TestAOPMethod Method=== ");
	}
	
	@After("execution(* com.elitecore.beans.UserInfo.*(..))")
	public void afterAOPMethod(JoinPoint joinPoint)
	{
		System.out.println("Afetr Aspect In TestAOPMethod Method");
		
		System.out.println("hijacked method : " + joinPoint.getSignature().getName());
		System.out.println("hijacked arguments : " + Arrays.toString(joinPoint.getArgs()));
	}
	@AfterReturning(pointcut = "execution(* com.elitecore.beans.UserInfo.*(..))",returning= "result")
	public void afterReturnAOPMethod(JoinPoint joinPoint, Object result)
	{
		System.out.println("AfetrReturn Aspect In TestAOPMethod Method ==== "+result);
	}
	@AfterThrowing(pointcut = "execution(* com.elitecore.beans.UserInfo.*(..))",throwing= "error")
	public void afterThrowAOPMethod(JoinPoint joinPoint, Throwable error)
	{
		System.out.println("afterThrow Aspect In TestAOPMethod Method ==== "+error);
	}
}